package com.hmall.search.web;


import com.hmall.search.pojo.ItemDto;
import com.hmall.search.pojo.PageResult;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.SearchService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {


    @Autowired
    private SearchService searchService;
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam("key")String key){
        return searchService.suggestion(key);

    }


    @PostMapping("/filters")
    public Map<String,List<String>> filters(@RequestBody RequestParams params){
        return searchService.filters(params);

    }


    @PostMapping("/list")
    public PageResult<ItemDto> list(@RequestBody RequestParams params){

        return searchService.list(params);

    }





}
